<jsp:include page="logincheck.jsp" />
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>

<jsp:useBean id="bill" class="se2.Bill" scope="request"/>
<jsp:setProperty name="bill" property="*"/>

<jsp:useBean id="phone" class="se2.PhoneAccount" scope="request"/>
<jsp:setProperty name="phone" property="*"/>

<html>

	<head>
		<title>Administration Console</title>
		<link rel="stylesheet" href="default.css" type="text/css" media="screen"></link>
		<script src="sorttable.js"></script>
		<script type="text/javascript" language="javascript" src="processPayment.js"></script>
	</head>

	<body>
		<div id="container">
			<div id="navigation">
<p>&nbsp;</p>
<jsp:include page="navigation.jsp" />
			</div>
			
			<div id="header">				
				<img src="images/header.png" />
			</div>

			<div id="content">
<!-- Main code -->

				<% 	bill.setPhoneAccount(Integer.parseInt(request.getParameter("id"))); 

					phone.setId(Integer.parseInt(request.getParameter("id")));
					phone.getPhoneAccountFromDatabase();
				%>
				
				<h1>Phone Account :: View Phone Bill</h1>
	
				<form name="payBill" id="payBill" method="post" action="payBillFunction.jsp?id=<%= request.getParameter("id") %>&cid=<%= request.getParameter("cid") %>" onSubmit="return validate(this);">
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td colspan="3"><h2>Process Payment</h2></td>
					</tr>
					<tr style="background-image: url('images/tableBackground.png');">
						<td style="background-image: url('images/tableBackground.png');" width="*">&nbsp;</td>
						<td style="background-image: url('images/tableBackground.png');" width="*">Balance: <%= phone.getFormattedBalance() %></td>
						<td style="background-image: url('images/tableBackground.png');" width="*">
							<input type="text" name="amount" id="amount" value="0.00"/>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td colspan="2" align="right">
							<input type="submit" value="Pay"/>
							<input type="button" value="Cancel" onclick="javascript:document.location.href='viewCustomerAccountDetails.jsp?id=<%= request.getParameter("cid") %>'" />
						</td>
					</tr>
				</table>
				</form>
	
				<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr style="background-image: url('images/tableBackground.png');">
						<th style="background-image: url('images/tableBackground.png');" width="*" class="sorttable_nosort tableHeader" align="center">&nbsp;<a href="addBill.jsp?id=<%= request.getParameter("id")%>&cid=<%= request.getParameter("cid")%>"><img src="images/add.png"/></th>
						<th style="background-image: url('images/tableBackground.png');" width="*" class="tableHeader" align="left">Period Start</th>
						<th style="background-image: url('images/tableBackground.png');" width="*" class="tableHeader" align="left">Period End</th>
						<th style="background-image: url('images/tableBackground.png');" width="*" class="tableHeader" align="center">Calls Made</th>
						<th style="background-image: url('images/tableBackground.png');" width="*" class="tableHeader" align="center">Bill Total</th>
						<th style="background-image: url('images/tableBackground.png');" width="*" class="sorttable_nosort tableHeader">&nbsp;</th>
					</tr>

					<% boolean odd = false; %>
					<c:forEach var="bitem" items="${bill.billsByPhoneAccount}">
						<% if (odd) { %>
							<tr style="background-image: url('images/tableBackground.png');">
						<% } else { %>
							<tr>
						<% } odd = !odd; %>
							<td align="center"><a href="showBill.jsp?bid=${bitem.id}&id=<%= request.getParameter("id") %>&cid=<%= request.getParameter("cid") %>"><img src="images/edit.png" alt="View" title="View"/></td>
							<td align="left" sorttable_customkey="${bitem.sortStartDate}">${bitem.formattedStartDate}</td>
							<td align="left" sorttable_customkey="${bitem.sortStartDate}">${bitem.formattedEndDate}</td>
							<td align="center">${bitem.callsMade}</td>
							<td align="right">${bitem.totalAmt}</td>
						</tr>
					</c:forEach>
				</table>


<!-- Main Code -->
			</div>

			<div id="footer">
<jsp:include page="footer.jsp" />
			</div>
		</div>
	</body>

</html>